/**
 * 使用context 做全局的状态管理
 */
import React from 'react';
const initState = {
  user: null,
  menu: [],
  routeItem: {
    name: '',
    children: '',
    path: '',
  },
};
function stateReducer(data, action) {
  console.log(action, data, '参数');
  switch (action.type) {
    case 'changeUser':
      return { ...data, user: action.data };
    case 'changeMenu':
      return { ...data, menu: action.data };
    case 'changeRouteItem':
      return { ...data, routeItem: action.data };
    default:
      return initState;
  }
}
let context = React.createContext();

export { stateReducer, initState, context };
